﻿using Application.AppService.CFSKAppService;
using AutoMapper;
using Domain.Entity;
using Microsoft.AspNetCore.Mvc;

namespace UI.Controllers.Customization_Settings_客户化设置_.Human_resource_file_management_人力资源档案管理_
{
	public class CFSKController : Controller
	{
		private readonly ICFSKAppService cFSKAppService;
		private readonly IMapper mapper;

		/// <summary>
		/// Ⅱ级机构设置
		/// </summary>
		/// <returns></returns>
		/// 
		public CFSKController(ICFSKAppService cFSKAppService, IMapper mapper)
		{
			this.cFSKAppService = cFSKAppService;
			this.mapper = mapper;
		}
		public IActionResult Index()
		{
			return View();
		}

		public async Task<IActionResult> AddCFSK(CFSK cFSK)
		{
			bool i = await cFSKAppService.AddCFSKAsync(cFSK);
			return Json(i);
		}

		public async Task<IActionResult> UpdateCFSK(CFSKUpdateDto cFSKUpdateDto)
		{
			CFSK cFSK = mapper.Map<CFSK>(cFSKUpdateDto);
			bool i = await cFSKAppService.UpdateCFSKAsync(cFSK);
			return Json(i);
		}

		public async Task<IActionResult> GetCFSK()
		{
			List<CFSK> cFSKs = await cFSKAppService.GetCFSKAsync();
			return Json(cFSKs);

		}


		[HttpGet("GetCFSKById/{ffid}")]
		public async Task<IActionResult> GetCFSKById(string ffid)
		{
			List<CFSK> cFSKss = await cFSKAppService.GetCFSKAsyncById(ffid);
			return Json(cFSKss);
		}

		public async Task<IActionResult> DeleteCFSK(int id)
		{
			bool i = await cFSKAppService.DeleteCFSKAsync(id);
			return Json(i);
		}
	}
}
